<!DOCTYPE html>
<html>

<head>
	<script type="text/javascript" src="../js/wap_meta.js"></script>
	<meta charset="utf-8" />
	<title></title>
	<script type="text/javascript" src="../js/jquery-2.1.1.js"></script>
	<link rel="stylesheet" href="../css/base.css" />
	<script type="text/javascript" src="../js/jquery.cookie.js"></script>
	<script type="text/javascript" src="../js/base64.js"></script>
	<script type="text/javascript" src="../js/jweixin-1.0.0.js"></script>
	<script type="text/javascript" src="../js/link.js"></script>
</head>
<style>
* {
	padding: 0;
	margin: 0;
	font-family: "微软雅黑";
}

body {
	background: #f0f0f0;
}

.title p {
	width: 750px;
	text-align: center;
	font-size: 34px;
	color: #004591;
	padding-top: 26px;
}

.back {
	position: absolute;
	top: 30px;
	left: 30px;
}

.content {
	position: absolute;
	top: 280px;
	padding-bottom: 100px;
}

.bar {
	position: relative;
	height: 90px;
}

.bar p {
	padding-top: 15px;
	padding-left: 30px;
	font-size: 32px;
	color: #333333;
}

.right {
	position: absolute;
	left: 240px;
	top: 16px;
}

.right input {
	font-size: 32px;
	color: #999999;
	border: 0;
	background: 0;
	width: 500px;
}

.line {
	position: absolute;
	left: 30px;
	width: 720px;
	top: 78px;
	height: 1px;
	background: #d0d0d0;
}

.comform {
	position: absolute;
	left: 30px;
	top: 570px;
}

.att1 {
	position: absolute;
	width: 750px;
	text-align: center;
	font-size: 32px;
	color: #0b52a1;
	top: 140px;
}

.att2 {
	position: absolute;
	width: 750px;
	text-align: center;
	font-size: 32px;
	color: #ff0000;
	top: 200px;
}

.attscan {
	position: absolute;
	top: 870px;
	left: 31px;
}

.scanBtn {
	position: absolute;
	top: 1020px;
	left: 30px;
	padding-bottom: 100px;
}

.attscan1 {
	position: absolute;
	top: 2000px;
}

</style>

<body>
	<div class="title">
		<p>公益护照激活</p>
		<img class="back" src="../img/activate/back.png" />
	</div>
	<div class="att1">输入护照编号/密码</div>
	<div class="att2">首次登陆，默认密码为证件编号后6位</div>
	<div class="content">
		<form id="searchForm">
			<div class="bar">
				<div class="left">
					<p>护照号码
						<font color='#FF3939'>*</font>
					</p>
				</div>
				<div class="right">
					<input name="name" type="text" placeholder="请输入您的护照号码">
				</div>
				<div class="line"></div>
			</div>
			<div class="bar">
				<div class="left">
					<p>密码
						<font color='#FF3939'>*</font>
					</p>
				</div>
				<div class="right">
					<input name="number" type="text" placeholder="请输入密码">
				</div>
				<div class="line"></div>
			</div>
		</form>
	</div>
	<img class="comform" src="../img/activate/next.png" />
	<div class="canScan">
		<img class="attscan" src="../img/activate/activate.png" />
		<img class="scanBtn" src="../img/activate/scan.png" />
	</div>
	<script>
	$(".canScan").hide();

	function getQueryString(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) {
			return unescape(r[2]);
		}
		return null;
	}
	var channelCode = getQueryString("channelCode");
	var businessCode = getQueryString("businessCode");
	var orderCode = getQueryString("orderCode");

	$.cookie("channelCode", channelCode);
	$.cookie("businessCode", businessCode);
	$.cookie("orderCode", orderCode);

	$(".back").click(function() {
		javascript: history.go(-1);
	})
	$(".comform").click(function() {
		if ($("#searchForm [name='name']").val() == "") {
			alert("请输入您的护照号码");
			return;
		}
		if ($("#searchForm [name='number']").val() == "") {
			alert("请输入密码");
			return;
		}

		$.post(linkObj.pplogin, {
			passport: $("#searchForm [name='name']").val(),
			pwd: $("#searchForm [name='number']").val()
		}, function(data) {
			if (data.code == 0) {
				$.cookie("passport", $("#searchForm [name='name']").val())

				var name = BASE64.encode(data.data.realName);
				document.location = linkObj.infoUrl + "?channelCode=" + $.cookie("channelCode") + "&businessCode=" + $.cookie("businessCode") + "&groupCode=" + data.data.groupCode + "&idNo=" + data.data.idNo + "&mobile=" + data.data.mobile + "&passportNo=" + data.data.passportNo + "&realName=" + name;
			} else {
				alert(data.message);
			}
		}, 'json')
	})

	$(".scanBtn").click(function() {
		wx.scanQRCode({
			needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
			scanType: ["qrCode"], // 可以指定扫二维码还是一维码，默认二者都有
			success: function(res) {
				$("#searchForm [name='name']").val(res.resultStr);
			}
		});
	})

	$.get(linkObj.jssdk + "?appid=zhiquyigjh1uv599f3c&shareurl=" + encodeURIComponent(location.href.split('#')[0]), function(data) {
		wx.config({
			debug: false,
			appId: data.appId,
			timestamp: data.timestamp,
			nonceStr: data.nonceStr,
			signature: data.signature,
			jsApiList: [
				'scanQRCode'
			]
		});
	}, 'json');

	var obj = new Object();
	obj.url = encodeURIComponent(location.href.split('#')[0]);

	$.ajax({
		url: linkObj.jssdk,
		type: "post",
		dataType: 'json',
		data: JSON.stringify(obj),
		contentType: "application/json",
		success: function(data) {

			wx.config({
				debug: false,
				appId: data.data.appId,
				timestamp: data.data.timestamp,
				nonceStr: data.data.nonceStr,
				signature: data.data.signature,
				jsApiList: [
					'scanQRCode'
				]
			});
			//						if(data.code == 0) {
			////							alert(data.message)
			//							if(checkBirthday(document.getElementById('card_no').value) >= 18){
			//								document.location = "number.html";
			//							}else{
			//								document.location = "parent.html";
			//							}
			//						} else {
			//							alert(data.message)
			//						}
		}
	});

	//			$.post(linkObj.jssdk, {url:encodeURIComponent(location.href.split('#')[0])}, function(data) {
	//				wx.config({
	//					debug: false,
	//					appId: data.data.appId,
	//					timestamp: data.data.timestamp,
	//					nonceStr: data.data.nonceStr,
	//					signature: data.data.signature,
	//					jsApiList: [
	//						'scanQRCode'
	//					]
	//				});
	//			},'json');

	wx.ready(
		function() {
			$(".canScan").show();
		}
	);

	wx.error(function(res) {

	});

	</script>
</body>

</html>

